import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from "axios";
import qs from "qs";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// 设置原型 this.$http.post
Vue.prototype.$http = axios;
// 设置默认的路径为后台服务器的ip和端口
Vue.prototype.$http.defaults.baseURL = "http://192.168.223.196:8333";
// 设置qs原型
Vue.prototype.$qs = qs;
Vue.use(ElementUI);
Vue.config.productionTip = false

//设置axios的请求拦截器
axios.interceptors.request.use(config => {
  //拦截到请求后，将token加到请求头中
  let token = localStorage.getItem("token");
  console.log("拦截请求，读取到token：" + token);
  if(token){
    config.headers.Authorization = token;
  }
  return config;
})

new Vue({
  router,
  render: function (h) { return h(App) }
}).$mount('#app')
